package jp.tkym.labs.store;


/**
 * Entity Meta infomation for Relational Database 
 * @author takayama
 */
class TableMeta {
	/**
	 * schemaName 
	 */
	String schemaName;
	
	/**
	 * table name
	 */
	private final String tableName;
	
	/**
	 * Column Names , exclude Primary Key;
	 */
	private final ColumnMeta[] columns;
	
	/**
	 * Property of Primary Key
	 */
	private final String[] keyNames;
	
	TableMeta(String tableName, String[] keyName, String[] columnName){
		this.tableName = tableName;
		this.keyNames = keyName;
		this.columns = new ColumnMeta[columnName.length];
		for(int i=0; i<columnName.length; i++)
			this.columns[i] = new ColumnMeta(columnName[i], null);
	}
	
	TableMeta(String tableName, String[] keyNames, ColumnMeta[] columns){
		this.tableName = tableName;
		this.keyNames = keyNames;
		this.columns = columns;	
	}
	
	String tableName(){
		return tableName;
	}
	
	String[] keyNames(){
		return keyNames;
	}
	
	String[] columnNames(){
		String[] array = new String[columns.length];
		for(int i=0; i<array.length; i++) 
			array[i] = columns[i].name;
		return array;
	}
	
	ColumnMeta[] columns() {
		return columns;
	}
	
	static class ColumnMeta{
		final String name;
		final String type;
		ColumnMeta(String name, String type){
			this.name = name;
			this.type = type;
		}
	}
	
}